<!doctype html>
<html>		
		<head>
			<meta charset="utf-8">
			<script src="js/angular.min.js"></script>
		</head>
		<body>
			<div ng-app="app" ng-controller="parentCtr">
			    <div ng-controller="childCtr1">name :
			        <input ng-model="name" type="text" ng-change="change(name);" />
			    </div>
			    <div ng-controller="childCtr2">Ctr1 name:
			        <input ng-model="ctr1Name" />
			    </div>
			</div>
		</body>



		<script type="text/javascript">
		var app = angular.module("app", []);

		app.controller("parentCtr", function($scope) {
			$scope.$on("Ctr1NameChange",
				function(event, name) {
					$scope.$broadcast("Ctr1NameChangeFromParrent", name);
				});
		});

		//控制器依赖注入方式1：推断依赖，参数名称就是依赖
		app.controller("childCtr1", function($scope) {
			$scope.change = function(name) {
				$scope.$emit("Ctr1NameChange", name);
			};
		});

		//控制器依赖注入方式2：先确定依赖名称，后面参数名就可以随意
		app.controller("childCtr2", ['$scope',
			function(scope) {
				scope.$on("Ctr1NameChangeFromParrent", function(event, name) {
					scope.ctr1Name = name;
				});
			}
		]);
		</script>
</html>
